﻿using QFramework;

namespace HKTools
{
    /// <summary>
    /// 完成当前任务的指令
    /// </summary>
    public class CMD_STS_CompleteCurrentTask : AbstractCommand
    {
        /// <summary>
        /// 任务队列类型
        /// </summary>
        STS_TaskQueueType taskQueueType;

        /// <summary>
        /// 延时完成时间
        /// </summary>
        float delayTime;

        /// <summary>
        /// 构造函数，完成当前任务指令
        /// </summary>
        public CMD_STS_CompleteCurrentTask(STS_TaskQueueType taskQueue, float delayTime = 0)
        {
            this.taskQueueType = taskQueue;

            if (delayTime <= 0)
                this.delayTime = 0;
            else
                this.delayTime = delayTime;
        }

        /// <summary>
        /// 执行指令，完成当前任务
        /// </summary>
        protected override void OnExecute()
        {
            // 调用任务系统，完成当前任务
            this.GetSystem<IHK_SimpleTaskSystem>().CompleteCurrentTask(taskQueueType, delayTime);
        }
    }
}